package cn.edu.nyist.service.impl;

import cn.edu.nyist.entity.RentHouse;
import cn.edu.nyist.entity.SellHouse;
import cn.edu.nyist.mapper.SellHouseMapper;
import cn.edu.nyist.service.SellHouseService;
import cn.edu.nyist.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (SellHouse)表服务实现类
 *
 * @author makejava
 * @since 2021-03-21 17:55:12
 */
@Service("sellHouseService")
public class SellHouseServiceImpl implements SellHouseService {
    @Autowired
    private SellHouseMapper sellHouseMapper;


    @Override
    public PageBean<SellHouse> queryPage(Map<String, Object> paramMap) {
        PageBean<SellHouse> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<SellHouse> datas = sellHouseMapper.queryList(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = sellHouseMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public PageBean<SellHouse> queryPageBelongUser(Map<String, Object> paramMap) {
        PageBean<SellHouse> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<SellHouse> datas = sellHouseMapper.queryListBelongUser(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = sellHouseMapper.queryCountBelongUser(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public PageBean<SellHouse> queryPageAreaDesc(Map<String, Object> paramMap) {
        PageBean<SellHouse> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<SellHouse> datas = sellHouseMapper.queryListAreaDesc(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = sellHouseMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public PageBean<SellHouse> queryPagePriceAsc(Map<String, Object> paramMap) {
        PageBean<SellHouse> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<SellHouse> datas = sellHouseMapper.queryListPriceAsc(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = sellHouseMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public int insertSellHouse(SellHouse sellHouse) {
        return sellHouseMapper.insertSellHouse(sellHouse);
    }

    @Override
    public SellHouse selectById(Integer id) {
        return sellHouseMapper.selectById(id);
    }

    @Override
    public int delBySellHouseIds(List<Integer> ids) {
        return sellHouseMapper.delBySellHouseIds(ids);
    }

    @Override
    public int editBySellHouse(SellHouse sellHouse) {
        return sellHouseMapper.editBySellHouse(sellHouse);
    }

    @Override
    public SellHouse selectByRegion(String region) {
        return sellHouseMapper.selectByRegion(region);
    }
}